#include <windows.h>
#include "CVanaTime.h"
#include "CGuildMenuPacket.h"

CGuildMenuPacket::CGuildMenuPacket(unsigned char holiday, unsigned char open, unsigned char close) {

	this->type = 0x86;
	this->size = 0x06;

	memset(data, 0, sizeof(data));

    unsigned int currDay;
    unsigned int currHour; 
	CVanaTime::getInstance()->getTime(NULL,NULL,NULL,NULL,&currHour,NULL,&currDay);

	if(currDay == holiday) {                               // Closed - holiday
		data[0x04-0x04] = 0x02;
		data[0x08-0x04] = holiday;
	} else if( (currHour < open) || (currHour >= close) ) { // Closed at this hour
		data[0x04-0x04] = 0x01; 
		packBitsBE(data+0x08-0x04, 0xFFFFFF, open, close-open);
	} else {                                               // Open
		data[0x04-0x04] = 0x00;
		packBitsBE(data+0x08-0x04, 0xFFFFFF, open, close-open);
	}

}

CGuildMenuPacket::~CGuildMenuPacket() {
}